﻿/*************************************************
* 文 件 名：AsciitoString
* 命名空间：WSNs
* 功    能：字节数组转换为String
* 作    者：ZGW (zgw@cqu.edu.cn)
* 团    队：Wireless Sensor Networks (WSNs)
* 创建时间：2015/3/4 10:46:51
* 版 本 号：V1.0.0.0
* 修改日志：
*************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WSNs
{
    class AsciitoString
    {
        /// <summary>
        /// Ascii码字节数组转换为String
        /// </summary>
        /// <param name="characters">字节数组</param>
        /// <returns></returns>
        public string FromAsciiByteArray(byte[] characters)
        {
            ASCIIEncoding encoding = new ASCIIEncoding();
            string constructedString = encoding.GetString(characters);
            return (constructedString);
        }

        /// <summary>
        /// Unicode码字节数组转换为String
        /// </summary>
        /// <param name="characters"></param>
        /// <returns></returns>
        public string FromUnicodeByteArray(byte[] characters)
        {
            UnicodeEncoding encoding = new UnicodeEncoding();
            string constructedString = encoding.GetString(characters);
            return (constructedString);
        }  
    }
}
